#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''=================================================
@Project -> File   ：db-toolkit -> singleton
@IDE    ：PyCharm
@Author ：Json
@Date   ：2025/3/24 11:55
@Desc   ：
=================================================='''

# singleton.py
from functools import lru_cache

def singleton(cls):
    """
    线程安全的单例装饰器
    """
    @lru_cache(maxsize=None)
    def get_instance(*args, **kwargs):
        return cls(*args, **kwargs)
    return get_instance